package cn.wolfcode.crm.service.impl;

import java.util.Collections;
import java.util.List;

import cn.wolfcode.crm.qo.PageResult;
import cn.wolfcode.crm.qo.QueryObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.wolfcode.crm.domain.Department;
import cn.wolfcode.crm.mapper.DepartmentMapper;
import cn.wolfcode.crm.service.IDepartmentService;

@Service
public class DepartmentServiceImpl implements IDepartmentService{
	@Autowired
	private DepartmentMapper departmentMapper;
	@Override
	public void insert(Department department) {
		departmentMapper.insert(department);
	}

	@Override
	public void delete(Long id) {
		departmentMapper.delete(id);
	}

	@Override
	public void update(Department department) {
		departmentMapper.update(department);
	}

	@Override
	public Department select(Long id) {
		Department department = departmentMapper.select(id);
		return department;
	}

	@Override
	public List<Department> list() {
		List<Department> list = departmentMapper.list();
		return list;
	}

	public PageInfo<Department> query(QueryObject qo) {
		PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Department> departments = departmentMapper.selectForList(qo);
        return new PageInfo<>(departments);
	}



}
